﻿<AddDataFormTemplateSpec 
	xmlns="bb_appfx_adddataformtemplate"
	xmlns:c="bb_appfx_commontypes" 
	ID="7fe27a1a-b312-4797-af32-8fd61940591e" 
	Name="TDSM Add Data Form"
	Description="Adds a TDSM Org Threshold entry" 
	Author="Blackbaud Professional Services"
	DataFormInstanceID="5b69abf9-629a-4610-8780-dd40c651969b" 
	RecordType="Organizational Hierarchy TDSM Threshold"
	c:SecurityUIFolder="TDSM"
	>

	<SPDataForm>
		<SaveImplementation SPName="USR_USP_DATAFORMTEMPLATE_ADD_TDSM_ORG_THRESHOLD">
			<c:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USR_USP_DATAFORMTEMPLATE_ADD_TDSM_ORG_THRESHOLD
(
  @ID uniqueidentifier = null output
 ,@CHANGEAGENTID uniqueidentifier = null
 ,@BUSINESSUNITCODEID uniqueidentifier = null
 ,@THRESHOLD money = null
)
as

set nocount on;
set @ID = isnull(@ID,newid());

if @CHANGEAGENTID is null begin
  exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
end;

declare @CURRENTDATE datetime = getdate();

begin try
  INSERT INTO USR_BUSINESSUNITCODE(
    ID
   ,THRESHOLD
   ,ADDEDBYID
   ,CHANGEDBYID
   ,DATEADDED
   ,DATECHANGED
  ) VALUES (
    @BUSINESSUNITCODEID
   ,@THRESHOLD
   ,@CHANGEAGENTID   
   ,@CHANGEAGENTID
   ,@CURRENTDATE
   ,@CURRENTDATE
  );
end try
begin catch
  exec dbo.USP_RAISE_ERROR
  return 1
end catch

return 0;
]]>
            </c:CreateProcedureSQL>
		</SaveImplementation>
	</SPDataForm>

    <c:FormMetaData FixedDialog="true">
		<c:FormFields>
            <c:FormField FieldID="BUSINESSUNITCODEID" DataType="Guid" Caption="Business unit" CaptionResourceKey="$$business_unit">
                <c:CodeTable CodeTableName="BUSINESSUNITCODE" />
            </c:FormField>
			<c:FormField FieldID="THRESHOLD" Caption="Minimum threshold" DataType="Money"/>
		</c:FormFields>
	</c:FormMetaData>
</AddDataFormTemplateSpec>